const express = require('express');
const router = express.Router();
const multer = require('multer');
const path = require('path');

const swiperService = require('../service/swiperService')

// 表单验证
const expressJoi = require('@escook/express-joi')
const { swiper_update_type, swiper_upLoad, swiper_delete } = require('../rule/swiperRule')

router.get('', swiperService.index);

router.get('/file/:name', swiperService.getFile);

router.get('/all', swiperService.allSwiper);

// 上传轮播图
router.post('/add', multer({
    dest: path.join(__dirname, '../file/swiper') //设置文件的存储路径
}).single('file'), swiperService.upLoad);

router.post('/updateType', expressJoi(swiper_update_type), swiperService.updateType);

router.post('/delete', expressJoi(swiper_delete), swiperService.delete);


module.exports = router;
